package com.ch.d0604;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "SaveBookServlet", value = "/SaveBookServlet")
public class SaveBookServlet extends HttpServlet {
    private static final long  serialVersionUID = 1L;

    private BookDao  bdao = new BookDao();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String id = request.getParameter("id");
        String name = request.getParameter("bookname");
        String press = request.getParameter("bookpress");
        String date = request.getParameter("pressdate");
        String author = request.getParameter("bookauthor");
        String count = request.getParameter("bokkconut");
        String image = request.getParameter("bookimage");
        try {
            bdao.save(id,name,press,date,author,count,image);
            response.getWriter().print("保存成功");
        }catch (Exception e){
            response.getWriter().print("保存失败");
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
